package com.example.myapplication

import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val linearLayout = LinearLayout(this)
        linearLayout.orientation = LinearLayout.VERTICAL

        val textView = TextView(this)
        textView.text = getString(R.string.hello)
        textView.textSize = 24f
        val imageView = ImageView(this)
        imageView.setImageResource(R.drawable.flag)

        val button = Button(this)
        button.text = getString(R.string.button_text)

        linearLayout.addView(textView)
        linearLayout.addView(imageView)
        linearLayout.addView(button)

        enableEdgeToEdge()

        setContentView(linearLayout)

        ViewCompat.setOnApplyWindowInsetsListener(linearLayout) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        button.setOnClickListener {
            textView.text = getString(R.string.button_clicked)
        }

    }
}